<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>1 原型属性 Object.keys</title>
    <script>
        function Person() {
        }

        Person.prototype.name = '雨夜';
        Person.prototype.age = 29;
        Person.prototype.job = 'Software Engineer';
        Person.prototype.sayName = function () {
            alert(this.name);
        };

        let keys = Object.keys(Person.prototype);
        console.log(keys);
        console.log('name' in Person.prototype);
        console.log(Person.hasOwnProperty('name'));
        let person1 = new Person();
        person1.address = '重庆';
        console.log(person1.hasOwnProperty('name'));
        console.log(Object.keys(person1));

        console.log(Object.getOwnPropertyNames(Person.prototype));
        console.log(Object.getOwnPropertyNames(person1));

        person1.sayName();

        function Person2() {
        }

        let friend = new Person2();
        Person2.prototype.sayName = function () {
            alert(this.name);
        };
        Person2.prototype = {
            constructor: Person2,
            name: '雨夜',
            age: 29,
            ojb: 'Software Engineer',
            sayName: function () {
                alert(this.name+' 重写');
            }
        };
        friend.sayName();

        let friend2 = new Person2();
        friend2.sayName();
    </script>
</head>
<body>

</body>
</html>